package cn.portx.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.bstek.bdf3.dorado.jpa.annotation.Generator;
import com.bstek.dorado.annotation.PropertyDef;

import cn.portx.annotation.ChineseField;
import cn.portx.policy.ChineseToCodeGeneratorPolicy;
import cn.portx.policy.CreateUserPolicy;
import cn.portx.policy.CreatedDatePolicy;
import cn.portx.policy.IdGeneratorPolicy;

/**
 * Model class of 船舶信息.
 * 
 * @author generated by ERMaster
 * @version $Id$
 */
@Entity
@Table(name = "T_VESSEL")
public class Vessel extends BaseEntity {

	/** serialVersionUID. */
	private static final long serialVersionUID = 1L;

	/** 所属船公司ID. */
	@Column(name = "SHIPPING_COMPANY_ID_", length = 60)
	@PropertyDef(label = "所属船公司ID", description = "所属船公司ID:所属船公司ID")
	private String shippingCompanyId;

	@Transient
	private ShippingCompany shippingCompany;

	/** 船名. */
	@Column(name = "NAME_", length = 100)
	@PropertyDef(label = "船名", description = "船名:船名")
	private String name;

	/** 代码. */
	@Column(name = "CODE_", length = 60)
	@ChineseField("name")
	@Generator(policy = ChineseToCodeGeneratorPolicy.class)
	@PropertyDef(label = "代码", description = "代码:代码")
	private String code;

	/** 类型. */
	@Column(name = "TYPE_", length = 1)
	@PropertyDef(label = "类型", description = "类型:类型,0：集装箱船舶；1：散货船舶")
	private String type;

	@Transient
	private List<Course> courses;

	/**
	 * Constructor.
	 */
	public Vessel() {
	}

	/**
	 * Set the 所属船公司ID.
	 * 
	 * @param shippingCompanyId
	 *            所属船公司ID
	 */
	public void setShippingCompanyId(String shippingCompanyId) {
		this.shippingCompanyId = shippingCompanyId;
	}

	/**
	 * Get the 所属船公司ID.
	 * 
	 * @return 所属船公司ID
	 */
	public String getShippingCompanyId() {
		return this.shippingCompanyId;
	}

	public ShippingCompany getShippingCompany() {
		return shippingCompany;
	}

	public void setShippingCompany(ShippingCompany shippingCompany) {
		this.shippingCompany = shippingCompany;
	}

	/**
	 * Set the 船名.
	 * 
	 * @param name
	 *            船名
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * Get the 船名.
	 * 
	 * @return 船名
	 */
	public String getName() {
		return this.name;
	}

	/**
	 * Set the 代码.
	 * 
	 * @param code
	 *            代码
	 */
	public void setCode(String code) {
		this.code = code;
	}

	/**
	 * Get the 代码.
	 * 
	 * @return 代码
	 */
	public String getCode() {
		return this.code;
	}

	/**
	 * Set the 类型.
	 * 
	 * @param type
	 *            类型
	 */
	public void setType(String type) {
		this.type = type;
	}

	/**
	 * Get the 类型.
	 * 
	 * @return 类型
	 */
	public String getType() {
		return this.type;
	}

	public List<Course> getCourses() {
		return courses;
	}

	public void setCourses(List<Course> courses) {
		this.courses = courses;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((this.getId() == null) ? 0 : this.getId().hashCode());
		return result;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		Vessel other = (Vessel) obj;
		if (this.getId() == null) {
			if (other.getId() != null) {
				return false;
			}
		} else if (!this.getId().equals(other.getId())) {
			return false;
		}
		return true;
	}

}
